/**
 * Copyright(C) 2008 - 2009 思敏工作室. All Rights Reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF 思敏工作室.
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */
package org.simin.smim.controller;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

import org.simin.smim.model.Message;

/**
 * Handler
 * 
 * @author ross
 * @version 0.1
 */
public class Handler implements Runnable {
	private Socket socket;

	public Handler(Socket socket) {
		this.socket = socket;
	}

	public void run() {
		try {
			ObjectInputStream ois = new ObjectInputStream(
					new BufferedInputStream(socket.getInputStream()));
			Message message = null;
			message = (Message) ois.readObject();
			System.out.println(message.getContent());
			ois.close();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} finally {
			try {
				if (socket != null) {
					socket.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
